package com.xzq.entity;

import java.io.Serializable;
import java.sql.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
/**
 * 用户实体类
 * @author Adam
 *
 */
@Entity
public class User implements Serializable {
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private Integer id;
	@Column(length=20,nullable=false,unique=true)
	private String name;
	@Column(length=20,nullable=false)
	private String pwd;
	@Column
	private Date birthday;
	@Column(length=20,nullable=false)
	private String realname;
	@Column(length=18,nullable=false)
	private String idcard;
	@Column(length=11)
	private String phone;
	@ManyToOne(cascade={CascadeType.MERGE},fetch=FetchType.EAGER)
	@JoinColumn(name="authority_id")
	private Authority authority;
	@OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY)
	@JoinColumn(name="user_id",insertable=true)
	private Set<Address> addresses = new HashSet<Address>();
	@OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY)
	@JoinColumn(name="user_id",insertable=true)
	private Set<Orders> orderses = new HashSet<Orders>();
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getPwd() {
		return pwd;
	}
	public void setPwd(String pwd) {
		this.pwd = pwd;
	}
	public Date getBirthday() {
		return birthday;
	}
	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}
	public String getRealname() {
		return realname;
	}
	public void setRealname(String realname) {
		this.realname = realname;
	}
	public String getIdcard() {
		return idcard;
	}
	public void setIdcard(String idcard) {
		this.idcard = idcard;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	public Authority getAuthority() {
		return authority;
	}
	public void setAuthority(Authority authority) {
		this.authority = authority;
	}
	public Set<Address> getAddresses() {
		return addresses;
	}
	public void setAddresses(Set<Address> addresses) {
		this.addresses = addresses;
	}
	public Set<Orders> getOrderses() {
		return orderses;
	}
	public void setOrderses(Set<Orders> orderses) {
		this.orderses = orderses;
	}
	public User() {
		super();
	}
	public User(Integer id, String name, String pwd, Date birthday, String realname, String idcard, String phone) {
		super();
		this.id = id;
		this.name = name;
		this.pwd = pwd;
		this.birthday = birthday;
		this.realname = realname;
		this.idcard = idcard;
		this.phone = phone;
	}
	public User(String name, String pwd, Date birthday, String realname, String idcard, String phone) {
		super();
		this.name = name;
		this.pwd = pwd;
		this.birthday = birthday;
		this.realname = realname;
		this.idcard = idcard;
		this.phone = phone;
	}
	
}
